<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commonjsp/jstl.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>工单类型管理</title>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<link rel="stylesheet" type="text/css" href="${prefix}/stylesheets/theme.css">
<link rel="stylesheet" type="text/css" href="${prefix}/stylesheets/reveal.css">
<link rel="stylesheet" type="text/css" href="${prefix}/lib/font-awesome/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="${prefix}/lib/bootstrap/css/bootstrap.css">

<script src="${prefix}/lib/jquery-1.8.1.min.js" type="text/javascript"></script>
<script src="${prefix}/lib/ajaxfileupload.js" type="text/javascript"></script>
<script src="${prefix}/lib/jquery-form.js" type="text/javascript"></script>
<script src="${prefix}/lib/jquery.reveal.js" type="text/javascript"></script>
<!-- Demo page code -->
<style type="text/css">
#line-chart {
	height:300px;
	width:800px;
	margin: 0px auto;
	margin-top: 1em;
}

.brand { font-family: georgia, serif; }
.brand .first {
	color: #ccc;
	font-style: italic;
}
.brand .second {
	color: #fff;
	font-weight: bold;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
	//页面准备好以后，查询该操作者可以进行操作的公司信息
	queryCompanySelect();
	
	//当公司选择发生变化时
	$("#companyandstoreSelect").change(function() {
		preQueryOrderTypesByCompanyid();
	});
});

//查询这个用户可用的公司信息（可维护的公司信息）
function queryCompanySelect() {
	$.ajax({
		type: "post",
		async: true,
		url: "${prefix}/company/queryCompany",
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			var listDatas = jsonData.data;
			var optionhtml = "";
			
			//开始构建公司
			for(var index = 0 ; listDatas != null && index < listDatas.length ; index++) {
				var optionItem = listDatas[index];
				
				optionhtml += "<option value=\"" + optionItem.uid + "\" label=\"" + optionItem.companyName + "\" style=\"color: #FF00FF;margin: 8px\" ";
				if(index == 0) {
					optionhtml += " selected ";
				}
				optionhtml += ">" + optionItem.companyName + "</option>";
			}
			
			$("#companyandstoreSelect").html(optionhtml);
			preQueryOrderTypesByCompanyid();
		}
	});
}

//查询指定的公司下的订单类型信息（包括系统工单类型和自定义工单类型）
function preQueryOrderTypesByCompanyid() {
	companyid = $("#companyandstoreSelect").val();
	$.ajax({
		type: "post",
		async: true,
		url: "${prefix}/ordertype/queryOrderTypesByCompanyid?companyid=" + companyid,
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			reviewTables(jsonData.data);
		}
	});
}

//当收到表格数据后，由这个方法进行表格重绘
function reviewTables(jsonobjects) {
	$("#ordertyleListDiv").html("");
	var htmlbody = "";
	for(var index = 0 ; jsonobjects != null && index < jsonobjects.length ; index++) {
		var ordertype = jsonobjects[index];
		htmlbody += "<tr>";
		htmlbody += "<td>" + ordertype.orderTypeName + "<br/>(" + ordertype.orderCode + ")</td>";
		htmlbody += "<td>" + ordertype.duration + "</td>";
		htmlbody += "<td>" + ordertype.integral + "</td>";
		if(ordertype.status == 1) {
			htmlbody += "<td>正常</td>";
		} else {
			htmlbody += "<td style=\"color:#FF0000\">禁用</td>";
		}
		//用户组
		var userGroups = ordertype.userGroups;
		htmlbody += "<td>";
		for(var sum = 0 ; userGroups != null && sum < userGroups.length ; sum++) {
			var userGroup = userGroups[sum];
			htmlbody += "<label>" + userGroup.groupName + "</label>"
		}
		
		//奖惩信息
		htmlbody += "<td>";
		var defines = ordertype.defines;
		for(var sum = 0 ; defines != null && sum < defines.length ; sum++) {
			var define = defines[sum];
			//用时
			if(define.durationChange < 0) {
				htmlbody += "<label>用时 " + define.durationChange + " 秒，";
				htmlbody += "积分 " + define.integralChange + " %</label>";
			} else {
				htmlbody += "<label style=\"color:#992200\">用时 " + define.durationChange + " 秒，";
				htmlbody += "积分 " + define.integralChange + " %</label>";
			}
		}
		htmlbody += "</td>";
		htmlbody += "<td align=\"center\" style=\"width: 210px\">";
		//自定义的订单类型有的功能
		if(ordertype.createType == 2) {
			htmlbody += "<a href=\"javascript:void(0);\" onclick=\"premodifyTypeOrder('" + ordertype.uid + "')\" style=\"margin-right: 10px\"  data-reveal-id=\"myTypeOrderDiv\">编辑</a>";
			if(ordertype.status == 1) {
				htmlbody += "<a href=\"javascript:void(0);\" style=\"margin-right: 10px\" onclick=\"updateOrderTypeStatus('" + ordertype.uid + "')\">禁用</a>";
			} else {
				htmlbody += "<a href=\"javascript:void(0);\" style=\"margin-right: 10px\" onclick=\"updateOrderTypeStatus('" + ordertype.uid + "')\">启用</a>";
			}
		}
		htmlbody += "<a href=\"javascript:void(0);\" style=\"margin-right: 10px\" onclick=\"perUserGroup('" + ordertype.uid + "')\" data-reveal-id=\"myUserGroupMappingDiv\">用户组</a>";
		htmlbody += "<a href=\"javascript:void(0);\" style=\"margin-right: 10px\" onclick=\"perAwardAndPunish('" + ordertype.uid + "','" + ordertype.orderTypeName + "' , " + ordertype.duration + "," + ordertype.integral + ")\" data-reveal-id=\"awardAndPunishDiv\">奖惩设置</a>";
		htmlbody += "</td>";
		htmlbody += "</tr>";
	}
	
	$("#ordertyleListDiv").html(htmlbody);
}

//创建工单类型前的数据初始化
function precrateTypeOrder() {
	$("#createType").val("2");
	$("#orderTypeName").val("");
	$("#orderDuration").val("180");
	$("#orderIntegral").val("20");
	$("#orderType_uid").val("");
	$("#orderCode").val("");
}

//修改工单类型前的数据初始化
function premodifyTypeOrder(ordertypeid) {
	$.ajax({
		type: "post",
		async: false,
		url: "${prefix}/ordertype/queryOrderTypesByid?ordertypeid=" + ordertypeid,
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			ordertype = jsonData.data;
			$("#orderType_uid").val(ordertype.uid)
			$("#createType").val("2");
			$("#orderTypeName").val(ordertype.orderTypeName);
			$("#orderDuration").val(ordertype.duration);
			$("#orderIntegral").val(ordertype.integral);
			$("#orderCode").val(ordertype.orderCode);
		}
	});
}

//保存编辑后的订单类型信息（视orderType_uid情况决定是添加操作还是修改操作）
function saveOrderType() {
	var uid = $("#orderType_uid").val();
	var typeName = $.trim($("#orderTypeName").val());
	var duration = $.trim($("#orderDuration").val());
	var integral = $.trim($("#orderIntegral").val());
	var orderCode = $.trim($("#orderCode").val());
	
	//判断填写的信息
	var goodForm = true;
	var error = "";
	//首先进行填写资料的判断
	if(typeName == "") {
		goodForm = false;
		error += "请填写工单类型名称！\r";
	}
	if(orderCode == "") {
		goodForm = false;
		error += "请填写工单类型编号！\r";
	}
	//系统默认编号不能使用
	var pattern = /^000[1-9]{1}$/;
	if(pattern.test(orderCode)) {
		goodForm = false;
		error += "0001——0009为系统保留编号，不能使用！\r";
	}
	pattern = /^[\d]+$/;
	if(!pattern.test(orderCode)) {
		goodForm = false;
		error += "工单类型编号只接受数字！\r";
	}
	//判断这个code是否被使用
	if(orderCode != "") {
		$.ajax({
			type: "post",
			async: false,
			url: "${prefix}/ordertype/existOrderTypeByCode?companyid=" + $("#companyandstoreSelect").val() + "&orderCode=" + orderCode,
			success: function(data) {
				var jsonData = eval('(' + data + ')');
				//错误信息
				if(jsonData.responsecode != "E200") {
					alert(jsonData.errorinfo);
					return;
				}
				
				if(jsonData.data) {
					goodForm = false;
					error += "工单类型编号已被使用，请更换！\r";
				}
			}
		});
	}
	if(duration == "") {
		goodForm = false;
		error += "请填写标准服务时间！\r";
	}
	if(integral == "") {
		goodForm = false;
		error += "请填写标准积分！\r";
	}
	if(!goodForm) {
		alert(error);
		return;
	}
	
	//===========发送信息
	var requestURL = "";
	var data = "";
	if(uid == "") {
		companyid = $("#companyandstoreSelect").val();
		requestURL = "${prefix}/ordertype/createOrderType";
		data= encodeURI("companyid=" + companyid + "&orderTypeName=" + typeName + "&orderCode=" + orderCode + "&integral=" + integral + "&duration=" + duration);
	} else {
		orderTypeid = $("#orderType_uid").val();
		requestURL = "${prefix}/ordertype/modifyOrderType";
		data = encodeURI("orderTypeid=" + orderTypeid + "&orderTypeName=" + typeName + "&orderCode=" + orderCode + "&integral=" + integral + "&duration=" + duration);
	}
	
	$.ajax({
		type: "post",
		async: true,
		url: requestURL,
		data: data,
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			//再次查询
			preQueryOrderTypesByCompanyid();
			alert("操作成功，您可以继续操作，也可以关闭对话框！");
		}
	});
}

function updateOrderTypeStatus(ordertypeid) {
	$.ajax({
		type: "post",
		async: false, 
		url: "${prefix}/ordertype/updateOrderTypeStatus?ordertypeid=" + ordertypeid, 
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			//重新查询列表
			preQueryOrderTypesByCompanyid();
		}
	});
}

//初始化指定工单类型的用户组的分配界面
function perUserGroup(ordertypeid , ordertypeName) {
	var useredGroups = null;
	var ableGroups = null;
	$("#showOrderTypeName").html("单据类型：" + ordertypeName + "&nbsp;&nbsp;&nbsp;绑定用户组");
	companyid = $("#companyandstoreSelect").val();
	$("#selected_ordertypeid").val(ordertypeid);
	//首先查询当前工单类型已经属于哪些用户组
	$.ajax({
		type: "post",
		async: false, 
		url: "${prefix}/storeuser/queryStroegroupByOrderTypeid?ordertypeid=" + ordertypeid, 
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			useredGroups = jsonData.data;
			var html = "";
			for(var sum = 0 ; useredGroups != null && sum < useredGroups.length ; sum++) {
				var userdGroup = useredGroups[sum];
				html += "<option value=\"" + userdGroup.uid + "\">" + userdGroup.groupName + "</option>";
			}
			
			$("#userdStoreGroups").html(html);
		}
	});
	
	//然后在查询哪些用户组还可以被加入
	companyid = $("#companyandstoreSelect").val();
	$.ajax({
		type: "post",
		async: false,
		url: "${prefix}/storeuser/queryStoregroupByCompanyid?companyid=" + companyid,
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			//可用的信息
			var html = "";
			ableGroups = jsonData.data;
			for(var index = 0 ; index < ableGroups.length ; index++) {
				var ableGroup = ableGroups[index];
				var canadd = true;
				for(var sum = 0 ; useredGroups != null && sum < useredGroups.length ; sum++) {
					var userdGroup = useredGroups[sum];
					//说明这个用户组，这个指定的用户已经加入了
					if(ableGroup.uid ==  userdGroup.uid) {
						canadd = false;
						break;
					}
				}
				
				if(canadd) {
					html += "<option value=\"" + ableGroup.uid + "\">" + ableGroup.groupName + "</option>";
				}
			}
			
			$("#ableStoreGroups").html(html);
		}
	});
}

//点击按钮，将用户添加到选定的用户组中
function appendtoGroups() {
	var selectedGroupids = $("#ableStoreGroups").val();
	if(selectedGroupids == null || selectedGroupids.length == 0) {
		alert("请至少选择一个用户组！");
		return;
	}
	
	//同步调用ajax接口，接口成功后，在进行页面表现的操作
	var ordertypeid = $("#selected_ordertypeid").val();
	var data = "ordertypeid=" + ordertypeid;
	for(var  index = 0 ; index < selectedGroupids.length ; index++) {
		data += "&groupids=" + selectedGroupids[index];
	}
	
	$.ajax({
		type: "post",
		async: false,
		url: "${prefix}/ordertype/bindUsergroupMapping",
		data: data,
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			//只有服务器端操作成功后，才进行页面上信息的操作
			var selectedOptions = $("#ableStoreGroups option:selected");
			$("#userdStoreGroups").append(selectedOptions);
			
			//重新查询列表
			preQueryOrderTypesByCompanyid();
		}
	});
}

//点击按钮，将用户移除选定的用户组中
function removetoGroups() {
	var selectedGroupids = $("#userdStoreGroups").val();
	if(selectedGroupids == null || selectedGroupids.length == 0) {
		alert("请至少选择一个用户组！");
		return;
	}
	
	//同步调用ajax接口，接口成功后，在进行页面表现的操作
	var ordertypeid = $("#selected_ordertypeid").val();
	var data = "ordertypeid=" + ordertypeid;
	for(var  index = 0 ; index < selectedGroupids.length ; index++) {
		data += "&groupids=" + selectedGroupids[index];
	}
	
	$.ajax({
		type: "post",
		async: false,
		url: "${prefix}/ordertype/unBindUsergroupMapping",
		data: data,
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			//只有服务器端操作成功后，才进行页面上信息的操作
			var selectedOptions = $("#userdStoreGroups option:selected");
			$("#ableStoreGroups").append(selectedOptions);
			
			//重新查询列表
			preQueryOrderTypesByCompanyid();
		}
	});
}

//初始化查询指定工单类型的奖惩信息
function perAwardAndPunish(ordertypeid , ordertypeName , duration , integral) {
	$.ajax({
		type: "post",
		async: false,
		url: "${prefix}/ordertype/queryOrderTypeDefine?ordertypeid=" + ordertypeid,
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			//文字信息
			$("#awardAndPunishFontDiv").html("工单类型：" + ordertypeName + "。奖惩情况设置：(标准耗时：" + duration + "；标准积分：" + integral + ")");
			
			//表单信息
			$("#awardAndPunishTbody").html("");
			var defines = jsonData.data;
			var html = "";
			for(var index = 0 ; index < defines.length ; index++) {
				var define = defines[index];
				html += "<tr>";
				//用时//积分
				if(define.durationChange < 0) {
					html += "<td>用时减少 " + (-1 * define.durationChange) + " 秒</td>";
					html += "<td>积分增加 " + define.integralChange + " %</td>";
					html += "<td><a href=\"javascript:void(0);\" onclick=\"removeOrderTypeDefine('" + define.uid + "','" + ordertypeid + "','" + ordertypeName + "'," + duration + " , " + integral + ")\">删除</a></td>";
				} else {
					html += "<td style=\"color:#992200\">用时增加 " + define.durationChange + " 秒</td>";
					html += "<td style=\"color:#992200\">积分减少 " + (-1 * define.integralChange) + " %</td>";
					html += "<td style=\"color:#992200\"><a href=\"javascript:void(0);\" onclick=\"removeOrderTypeDefine('" + define.uid + "','" + ordertypeid + "','" + ordertypeName + "'," + duration + " , " + integral + ")\">删除</a></td>";
				}
			}
			
			//添加表单部分
			html += "<tr>";
			html += "<td>";
			html += "<div style=\"float: left;\"><input type=\"text\" name=\"\" style=\"width:60px;height: 30px\" maxlength=\"5\" id=\"appendDurationChange\"/></div>";
			html += "</td>";
			html += "<td>";
			html += "<div style=\"float: left;\"><input type=\"text\" name=\"\" style=\"width:60px;height: 30px\" maxlength=\"5\" id=\"appendIntegralChange\"/> %</div>";
			html += "</td>";
			html += "<td>";
			html += "<a href=\"javascript:void(0);\" onclick=\"appendAwardAndPunish('" + ordertypeid + "','" + ordertypeName + "'," + duration + " , " + integral + ")\">保存</a>";
			html += "</td>";
			html += "</tr>";
			
			$("#awardAndPunishTbody").html(html);
		}
	});
}

//增加一条新的奖惩信息
function appendAwardAndPunish(ordertypeid , ordertypeName , duration , integral) {
	//首先是判断填写信息的正误性
	var companyid = $("#companyandstoreSelect").val();
	var durationChange = $.trim($("#appendDurationChange").val());
	var integralChange = $.trim($("#appendIntegralChange").val());
	var goodForm = true;
	var error = "";
	//耗时信息 - duration > 0
	if(durationChange == "") {
		goodForm = false;
		error += "请正确填写耗时变化值！\r";
	}
	if((duration * 1) + (durationChange * 1) <= 0) {
		goodForm = false;
		error += "耗时变化超过了标准耗时，请重新填写！\r";
	}
	var pattern = /^[\-]?[\d]{1,3}$/;
	if(integralChange == ""
		|| !pattern.test(integralChange) || integralChange == 0) {
		goodForm = false;
		error += "请填写正确的积分增减信息！\r";
	}
	if(integralChange < -100) {
		goodForm = false;
		error += "减少的积分不能超过100%！\r";
	}
	if(durationChange < 0 && integralChange < 0) {
		goodForm = false;
		error += "耗时减少的情况加，应该设置奖励积分增加！\r";
	}
	if(durationChange > 0 && integralChange > 0) {
		goodForm = false;
		error += "耗时增加的情况加，应该设置标准积分减少！\r";
	}
	if(!goodForm) {
		alert(error);
		return;
	}
	
	//=========开始增加积分
	var data = "ordertypeid=" + ordertypeid + "&durationChange=" + durationChange + "&integralChange=" + integralChange
	$.ajax({
		type: "post",
		async: false,
		url: "${prefix}/ordertype/appendOrderTypeDefine",
		data: data,
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			//成功清空现有信息，刷新列表
			perAwardAndPunish(ordertypeid , ordertypeName , duration , integral);
			preQueryOrderTypesByCompanyid();
		}
	});
}

//删除指定的奖惩信息
function removeOrderTypeDefine(defineid , ordertypeid , ordertypeName , duration , integral) {
	$.ajax({
		type: "post",
		async: false,
		url: "${prefix}/ordertype/removeOrderTypeDefine?defineid=" + defineid,
		success: function(data) {
			var jsonData = eval('(' + data + ')');
			//错误信息
			if(jsonData.responsecode != "E200") {
				alert(jsonData.errorinfo);
				return;
			}
			
			//成功清空现有信息，刷新列表
			perAwardAndPunish(ordertypeid , ordertypeName , duration , integral);
		}
	});
}
</script>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
	<script src="${prefix}/javascripts/html5.js"></script>
<![endif]-->
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="${prefix}/lib/font-awesome/docs/assets/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" href="${prefix}/lib/font-awesome/docs/assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="${prefix}/lib/font-awesome/docs//assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="${prefix}/lib/font-awesome/docs//assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="${prefix}/lib/font-awesome/docs//assets/ico/apple-touch-icon-57-precomposed.png">
</head>

<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7"> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8"> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> 
<body>
<!--<![endif]-->

<div class="navbar">
	<%@ include file="/commonjsp/userbar.jsp"%>
</div>

<div class="container-fluid">
	<div class="row-fluid">
		<%@ include file="/commonjsp/mainmenu.jsp"%>
		<!-- 列表 -->
		<div class="span9">
			<!-- 列表头 -->
			<h1 class="page-title">工单类型</h1>
			<div class="btn-toolbar">
				<a href="javascript:void(0);" class="btn btn-primary" onclick="precrateTypeOrder()" data-reveal-id="myTypeOrderDiv"><i class="icon-plus"></i> 新建工单类型 </a>
				<div class="btn-group"></div>
			</div>
			
			<!-- 公司树 -->
			<div class="well" style="width: 150px;height: 480px; float: left; margin-right:10px ; padding: 5px ; overflow-y:none ; overflow-x:none;">
				<input type="hidden" name="admin_name" id="admin_name" value="${admin.userName }"/>
				<input type="hidden" name="admin_level" id="admin_level" value="${admin.adminLevel }"/>
				<input type="hidden" name="admin_companyid" id="admin_companyid" value="${admin.company.uid }"/>
				<select style="width: 100% ; height: 100% ; border: 0px" multiple="multiple" name="companyandstoreSelect" id="companyandstoreSelect">
					
				</select>
			</div>
			
			<!-- 列表正文 -->
			<div class="well" style="float: left; min-width: 900px;">
				<table class="table">
					<thead>
						<tr>
							<th>类型名</th>
							<th>标准时间</th>
							<th>默认积分</th>
							<th>状态</th>
							<th>绑定用户组</th>
							<th>奖惩设置</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody id="ordertyleListDiv">
						
					</tbody>
				</table>
			</div>
		</div>
	</div>
	
	<!-- Le javascript
	================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->
	<script src="${prefix}/lib/bootstrap/js/bootstrap.js"></script>
	
	<!-- 工单类型详情编辑 -->
	<div id="myTypeOrderDiv" class="reveal-modal" style="width: 200px;height: 300px;">
		<input type="hidden" id="createType" value=""/>
		<input type="hidden" id="orderType_uid" value=""/>
		<label style="padding: 5px;margin: 0px;">工单类型名称：</label>
		<label style="padding: 5px;margin: 0px;">
			<input type="text" id="orderTypeName" value="" maxlength="64" style="width: 180px ; height: 30px ; padding: 0px ; margin: 0px;"/>
		</label>
		<label style="padding: 5px;margin: 0px;">工单类型编号：</label>
		<label style="padding: 5px;margin: 0px;">
			<input type="text" id="orderCode" value="" maxlength="10" style="width: 180px ; height: 30px ; padding: 0px ; margin: 0px;"/>
		</label>
		<label style="padding: 5px;margin: 0px;">标准服务时间（秒）：</label>
		<label style="padding: 5px;margin: 0px;">
			<input type="text" id="orderDuration" value="180" maxlength="4" style="width: 180px ; height: 30px ; padding: 0px ; margin: 0px;"/>
		</label>
		<label style="padding: 5px;margin: 0px;">默认积分：</label>
		<label style="padding: 5px;margin: 0px;">
			<input type="text" id="orderIntegral" value="20" maxlength="3" style="width: 180px ; height: 30px ; padding: 0px ; margin: 0px;"/>
		</label>
		<label style="padding: 5px;margin: 0px;">
			<button id="myorderTypeButton" onclick="saveOrderType()" class="btn btn-primary"><i class="icon-save"></i> Save </button>
		</label>
		<a class="close-reveal-modal">×</a>
	</div>
	
	<!-- 单据类型和用户组绑定 -->
	<div id="myUserGroupMappingDiv" class="reveal-modal" style="width: 600px;height: 360px; overflow-x: hidden; overflow-y: hidden">
		<input type="hidden" id="selected_ordertypeid" value=""/>
		<font color="#999999" id="showOrderTypeName"></font><br/>
		<div style="width: 250px ; height: 70% ; margin: 20px; border-color: #EEEE00 ; float: left;">
			<div style="float: left;">
			<label>可选择的用户组：</label>
			<select multiple="multiple" style="width: 250px;height: 100%" id="ableStoreGroups"></select>
			</div>
			<label><a href="javascript:void(0);" onclick="appendtoGroups()" class="btn">加入到用户组</a></label>
		</div> 
		<div style="width: 250px ; height: 70% ; margin: 20px ; border-color: #EEEE00 ; float: left;">
			<div style="float: left;">
			<label>已选择的用户分组：</label> 
			<select multiple="multiple" style="width: 250px;height: 100%" id="userdStoreGroups"></select>
			</div>
			<label><a href="javascript:void(0);" onclick="removetoGroups()" class="btn">用户组移除</a></label>
		</div>
		<a class="close-reveal-modal">×</a>
	</div>
	
	<!-- 奖惩情况 -->
	<div id="awardAndPunishDiv" class="reveal-modal" style="width: 480px;height: 380px; overflow-x: hidden; overflow-y: hidden">
		<label style="padding: 5px;margin: 0px;" id="awardAndPunishFontDiv">工单类型：消费类工单。奖惩情况设置</label>
		<label style="padding: 5px;margin: 0px; color:#FF0000">耗时增减：填写正数表示耗时增加的情况；填写负数表示耗时减少的情况</label>
		<label style="padding: 5px;margin: 0px; color:#FF0000">积分增减：填写正数表示增加积分；填写负数表示减少积分</label>
		<table class="table">
			<thead>
				<tr>
					<th>耗时增减(秒)</th>
					<th>积分增减(%)</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody id="awardAndPunishTbody">
				
			</tbody>
		</table>
	</div>
</div>
</body>
</html>